﻿<!--#INCLUDE FILE="config.asp"-->
<!--#include virtual ="/Email/email-costabaja.asp"-->
<%
 if(Session("SalesAccessLevel") <> 1 and Session("SalesAccessLevel") <> 4 ) then
	Response.Redirect("default.asp?msg=invalid")
end if

sqlstring2 = "SELECT * FROM Sales WHERE SaleID ="& Session("SalesId")  
	
	set objConnect1 = server.createObject("ADODB.Connection")   

	objConnect1.Open conStr

	set TblTemp1 = server.createobject("Adodb.Recordset")
		
		TblTemp1.Open sqlstring2, objConnect1
		
	If not TblTemp1.EOF Then
		email = TblTemp1("Email")
		emailpass = TblTemp1("EmailPassword")
	end if 

Dim attachment

if (request("emailto") <> "") then 
	emailto = request("emailto")
	subject = request("subject")
	content = request("content")
	guestid = request("guestid")
	nameGuest = request("nameGuest")
	attach = request("attach")
	
	content = Replace(content,"../images/","www.feifinancial.com/callcenter/images/")
end if	

		 Dim FEiEmail

		 FEiEmail="fulfillment@feifinancial.com"
		
		 'send mail
		
		 From = "discover@costabaja.com"
		 FEiEmail = FEiEmail & ";" & emailto
		
		 if (attach = "English") then
			Call EmailCdonts(From,FEiEmail,"",subject,content ,0,""&Server.MapPath("Letter/CartaAutorizacionCargoTarjetaENGLISH xls.pdf"),2,email,emailpass)
		 elseif (attach = "Espanol") then
			 Call EmailCdonts(From,FEiEmail,"",subject,content ,0,""&Server.MapPath("Letter/CartaAutorizacionCargoTarjetaESPAÑOL.xls.pdf"),2,email,emailpass)
		 else
			 Call EmailCdonts(From,FEiEmail,"",subject,content ,0,"",2,email,emailpass)
		 end if
			'On Error Resume Next 
			

		 If Err.Number <> 0 Then
		 Dim output
		   output = "This means there is most likely a problem with the" & vbCrLf
		   output = output + """ConnectionString"" info that you specified.<br>" & vbCrLf
		   response.write output
		 Else
			 set objConnect = server.createObject("ADODB.Connection")       
			 objConnect.open conStr

			 Set oCmd = Server.CreateObject("ADODB.Command")

			 oCmd.ActiveConnection = objConnect
			 oCmd.CommandText = "sp_send_mail_prospect" 
			 oCmd.CommandType = 4
			
			 Set content = oCmd.CreateParameter("@content", 200,1,3000, content)
			 oCmd.Parameters.Append content
			
			 Set guestid = oCmd.CreateParameter("@guestid", 3,1,100, guestid)
			 oCmd.Parameters.Append guestid
			
			 Set userid = oCmd.CreateParameter("@userid", 3,1,100,session("SalesAccessLevel"))
			 oCmd.Parameters.Append userid

			 set rss = oCmd.execute
			
			 Response.Write("Send Successfully! Click <a href=""sales-dashboard.asp"">here</a> to redirect Dashboard")
		 end if
%>